home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_098 / hddriver / driver / posn.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  41 lines

  1.  
  2. /*
  3.  * Copyright 1987 Alan Kent
  4.  *
  5.  * Permission is granted to redistribute this code as long
  6.  * as this message is retained in the code and the code is
  7.  * not sold without written permission from the author.
  8.  *
  9.  * UUCP: {seismo,hplabs,mcvax,ukc,nttlab}!munnari!goanna.oz!ajk
  10.  * ACSnet: ajk@goanna.oz
  11.  * ARPA: munnari!goanna.oz!ajk@SEISMO.ARPA
  12.  */
  13.  
  14. #include "hd.h"
  15.  
  16.  
  17. BOOL
  18. calc ( ior , posn , num_secs )
  19. register struct IOStdReq *ior;
  20. register struct posn *posn;
  21. LONG *num_secs;
  22. {
  23.     if (  ior->io_Offset < 0
  24.     ||    ior->io_Length < 0
  25.     ||  ( ior->io_Offset % HD_SECTOR ) != 0
  26.     ||  ( ior->io_Length % HD_SECTOR ) != 0 ) {
  27.         ior->io_Error = TDERR_NotSpecified;
  28.         return ( FALSE );
  29.     }
  30.     posn->block = ior->io_Offset / HD_SECTOR;
  31.     posn->sector = posn->block % first.sectors;
  32.     posn->surface = ( posn->block / first.sectors ) % first.heads;
  33.     posn->cylinder = posn->block / ( first.sectors * first.heads );
  34.     *num_secs = ior->io_Length / HD_SECTOR;
  35.     if ( posn->cylinder >= first.cylinders ) {
  36.         ior->io_Error = TDERR_NotSpecified;
  37.         return ( FALSE );
  38.     }
  39.     return ( TRUE );
  40. }
  41.